import request from './config'

// 获取活动列表
export const getActivities = (params) => {
  return request({
    url: '/activities',
    method: 'get',
    params
  })
}

// 获取活动详情
export const getActivityDetail = (id) => {
  return request({
    url: `/activities/${id}`,
    method: 'get'
  })
}

// 创建活动
export const createActivity = (data) => {
  return request({
    url: '/activities',
    method: 'post',
    data
  })
}

// 更新活动
export const updateActivity = (id, data) => {
  return request({
    url: `/activities/${id}`,
    method: 'put',
    data
  })
}

// 删除活动
export const deleteActivity = (id) => {
  return request({
    url: `/activities/${id}`,
    method: 'delete'
  })
}

// 获取活动签到记录
export const getActivityAttendance = (id, params) => {
  return request({
    url: `/activities/${id}/attendance`,
    method: 'get',
    params
  })
}

// 更新活动签到状态
export const updateAttendance = (activityId, volunteerId, data) => {
  return request({
    url: `/activities/${activityId}/attendance/${volunteerId}`,
    method: 'put',
    data
  })
}

// 获取活动考核记录
export const getActivityAssessment = (id, params) => {
  return request({
    url: `/activities/${id}/assessment`,
    method: 'get',
    params
  })
}

// 更新活动考核分数
export const updateAssessment = (activityId, volunteerId, data) => {
  return request({
    url: `/activities/${activityId}/assessment/${volunteerId}`,
    method: 'put',
    data
  })
}

export const signupActivity = (activityId) => {
  return request({
    url: `/activities/${activityId}/signup`,
    method: 'post'
  })
}

export const checkInActivity = (activityId) => {
  return request({
    url: `/activities/${activityId}/checkin`,
    method: 'post'
  })
} 